#include <gtest/gtest.h>
#include <tiredis/toml.h>
#include <tiredis/build.h>
#include <fstream>

TEST(TomlTests, TomlParse)
{
    std::ifstream ifs("foo.toml");
    toml::ParseResult pr = toml::parse(ifs);

    if (!pr.valid()) {
        std::cout << pr.errorReason << std::endl;
        return;
    }
    const toml::Value& v = pr.value;
    const toml::Value* x = v.find("table.key");
    if (x && x->is<std::string>()) {
        std::cout << x->as<std::string>() << std::endl;
    } else if (x && x->is<int>()) {
        std::cout << x->as<int>() << std::endl;
    }

}
